package com.wuxu.ads_no

import android.app.Application
import android.content.Intent
import android.os.Build
import com.wuxu.ads_no.base.service.BaseService
import com.wuxu.ads_no.keepalive.CrashHandler
import com.wuxu.ads_no.keepalive.KeepAlivePresenter
import com.wuxu.ads_no.util.AppUtils

/**
 *@author wuxu 21057340
 *@date 2024/2/19 6:37 PM
 */
class AdKillerApplication:Application() {
    override fun onCreate() {
        super.onCreate()
        if (AppUtils.isAppProcess(this)){
            CrashHandler.getInstance().init(this)
            KeepAlivePresenter.getInstance().bindKeepAliveService(this)

            //启动前台服务
            val mIntent = Intent(this, BaseService::class.java)
            mIntent.action = "com.wuxu.ads_no.base.service"
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                this.startForegroundService(mIntent)
            } else {
                this.startService(mIntent)
            }
        }
    }
}